﻿namespace Huayou.UI.WebControls
{
    using System;
    using System.Web.UI;
    using System.Xml;

    internal abstract class MenuGroupRenderBase : MenuGroup
    {
        public MenuGroupRenderBase(XmlElement node, WebMenu menu) : base(node, menu)
        {
        }

        public void Render(HtmlTextWriter output)
        {
            switch (base.Orientation)
            {
                case "horizontal":
                    this.RenderHorizontal(output);
                    return;

                case "vertical":
                    this.RenderVertical(output);
                    return;
            }
            this.RenderVertical(output);
        }

        public abstract void RenderEnd(HtmlTextWriter output);
        public abstract void RenderHorizontal(HtmlTextWriter output);
        public abstract void RenderItem(HtmlTextWriter output, XmlNode itemNode);
        public abstract void RenderStart(HtmlTextWriter output);
        public abstract void RenderVertical(HtmlTextWriter output);
        protected bool useDefaultStyle()
        {
            bool flag = true;
            if (((base.Menu.DefaultGroupCssClass != null) || (base.Menu.DefaultItemCssClass != null)) || (base.CssClass != null))
            {
                flag = false;
            }
            for (int i = 0; i < base.GroupNode.ChildNodes.Count; i++)
            {
                if (((base.GroupNode.ChildNodes[i].NodeType == XmlNodeType.Element) && (base.GroupNode.ChildNodes[i].Name == "MenuItem")) && ((base.GroupNode.ChildNodes[i].Attributes["CssClass"] != null) || (base.GroupNode.ChildNodes[i].Attributes["Image"] != null)))
                {
                    flag = false;
                }
            }
            if (flag)
            {
                base.Menu.useDefaultStyle = true;
            }
            return flag;
        }
    }
}

